v1<- -3:3
v1[v1%%3==0]<-0
mat<-matrix(c(NA,9,17,25,3,NA,19,27,5,13,NA,29,7,15,23,NA),nrow = 4,byrow = TRUE)
apply(mat,2,sum)
a<-data.frame(letters[1:8],numbers=c(1:8))
as.matrix(a)
list(letters,c(0:9),factor(1:3,levels = c(1:3)))
dim1<-c("28岁","33岁")
dim2<-c("1月工资","2月工资","3月工资")
dim3<-c("老八","雷军","嗨嗨嗨","孙笑川")
aa<-array(6000:10000,c(2,3,4),dimnames = list(dim1,dim2,dim3))
x <- c(2,6,8,8,12,16,20,20,22,26)
y <- c(58,105,88,118,117,137,157,169,149,202)
relation <- lm(y~x) 
print(relation)
print(summary(relation))
a <- data.frame(x = 24)
result <-  predict(relation,a,interval="confidence")  
print(result)

summary(relation)$r.squared
plot(x,y,col = "blue",main = "学生人数与销售额关系",
abline(lm(y~x)),cex = 1.5,pch = 16,xlab = "学生人数",ylab = "销售额")
b <- data.frame(x = 12)
result <-  predict(relation,b)
print(result)
c <- data.frame(x = 24)
result <-  predict(relation,c)
print(result)
y.res<-resid(relation)
plot(x,y.res,col = "blue",main = "学生人数与销售额关系",
    xlab = "学生人数",ylab = "残差") 
abline(0,0) 
y.stdres<-rstandard(relation)
plot (x,y.stdres,col = "blue",main = "学生人数与销售额关系",
      xlab = "学生人数",ylab = "残差") 
abline(0,0)